﻿import mx.utils.Delegate;
/**
 * ...
 * @author wangjun
 */
class cn.eminia.A2.ui.Cursor 
{
	private var id:String;
	private var mc:MovieClip;
	private var xo:Number;
	private var yo:Number;
	
	public function Cursor(what,vars) 
	{	
		if(what==null){throw new Error("Cursor 缺少关键对象 what")}
		if (what.constructor == MovieClip) {
			this.mc = what;
			this.id = null;
			this.xo = (vars.xo!=null)?vars.xo:0;
			this.yo = (vars.yo!=null)?vars.yo:0;
		}
		else if (what.constructor == String) {		
			this.mc = null;
			this.id = what;
			
		}
		if (this.mc) {
			this.mc._visible =false;
		}		
	}
	public function show(_soon:Boolean) {	
		var soon = (_soon == null)?true:_soon;
		this.mc.onMouseMove  = Delegate.create(this,function() {
			//trace("this.mc "+ this.mc);
			this.mc._x = _root._xmouse+this.xo;
			this.mc._y = _root._ymouse+this.yo;
			if (!soon && !this.mc._visible) this.mc._visible = true;
			updateAfterEvent();		
			this.mc.onMouseMove  = Delegate.create(this,function() {
				this.mc._x = _root._xmouse+this.xo;
				this.mc._y = _root._ymouse+this.yo;
				updateAfterEvent();		
			})
		});	 
		if(soon)this.mc._visible =true; 
	}
	public function hidden() {	 
		this.mc._visible =false;
		delete this.mc.onMouseMove ;
	}
	
}